﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using snat.model.events;
using snat.proxy.items;

namespace snat.model.Monitors.MessageCount
{
    public class EveryCountMonitor : Monitor<MessageArgs>
    {
        private long everyCount;
        private long count = 0;
        public EveryCountMonitor(EventHandler<MessageArgs> _source, long _everyCount) {
            //this doesn't work. its just passing in null
            _source += isReady;
            everyCount = _everyCount;
        }


        public event EventHandler<MessageArgs> Matched;
        private void isReady(object src, MessageArgs m){
            count++;
            count %= everyCount;
            if (count == 0 && Matched != null) {
                Matched(src, m);
            }
        }




    }
}
